package com.engineering.elink.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.engineering.elink.co.PersonDynamicCo;
import com.engineering.elink.common.Constant;
import com.engineering.elink.common.Pagination;
import com.engineering.elink.dao.PersonDynamicMapper;
import com.engineering.elink.dao.UserMapper;
import com.engineering.elink.service.PersonDynamicService;

@Service
public class PersonDynamicServiceImpl implements PersonDynamicService {

@Autowired
private UserMapper userMapper;
	@Autowired
	private PersonDynamicMapper personDynamicMapper;
	
	@Override
	public Map<String, Object> getPersonDynamicList(
			PersonDynamicCo PersonDynamicCo) {
		Map<String, Object> userMap = userMapper.selectByUserId(PersonDynamicCo.getUserId());
		if (userMap != null && (int)userMap.get("userType") == Constant.personUserType) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("list", personDynamicMapper.selectPersonDynamicList(PersonDynamicCo));
			map.put("Pagination", new Pagination(PersonDynamicCo, personDynamicMapper.selectPersonDynamicListCount(PersonDynamicCo)));
			return map;
		}
		return null;
	}
}
